# RUN: yaml2obj %p/Inputs/arm64-slice.yaml -o %t-arm64.o
# RUN: yaml2obj %p/Inputs/armv7-slice.yaml -o %t-armv7.o
# RUN: yaml2obj %p/Inputs/i386-x86_64-universal.yaml -o %t-universal.o

# segalign expects an architecture type followed by a hexadecimal value for alignment

# RUN: llvm-lipo %t-universal.o %t-arm64.o -create -o %t.o -segalign arm64 100
# RUN: llvm-objdump %t.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARM64 %s
# CHECK_SMALL_ARM64: nfat_arch 3
# CHECK_SMALL_ARM64-NEXT: architecture i386
# CHECK_SMALL_ARM64: offset 4096
# CHECK_SMALL_ARM64-NEXT: size 432
# CHECK_SMALL_ARM64-NEXT: align 2^12 (4096)
# CHECK_SMALL_ARM64-NEXT: architecture x86_64
# CHECK_SMALL_ARM64: offset 8192
# CHECK_SMALL_ARM64-NEXT: size 488
# CHECK_SMALL_ARM64-NEXT: align 2^12 (4096)
# CHECK_SMALL_ARM64-NEXT: architecture arm64
# CHECK_SMALL_ARM64: offset 8704
# CHECK_SMALL_ARM64-NEXT: size 516
# CHECK_SMALL_ARM64-NEXT: align 2^8 (256)
######     WITHOUT SEGALIGN      ######
# RUN: llvm-lipo %t-universal.o %t-arm64.o -create -o %t-nosegalign.o
# RUN: llvm-objdump %t-nosegalign.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARM64_NO_SEGALIGN %s
# CHECK_SMALL_ARM64_NO_SEGALIGN: architecture arm64
# CHECK_SMALL_ARM64_NO_SEGALIGN: offset 16384
# CHECK_SMALL_ARM64_NO_SEGALIGN-NEXT: size 516
# CHECK_SMALL_ARM64_NO_SEGALIGN-NEXT: align 2^14 (16384)

# RUN: llvm-lipo %t.o -thin arm64 -o %thin-arm64.o
# RUN: cmp %thin-arm64.o %t-arm64.o

# RUN: llvm-lipo %t-universal.o %t-armv7.o -create -o %t2.o -segalign armv7 100
# RUN: llvm-objdump %t2.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARMV7 %s
# CHECK_SMALL_ARMV7: nfat_arch 3
# CHECK_SMALL_ARMV7-NEXT: architecture armv7
# CHECK_SMALL_ARMV7: offset 256
# CHECK_SMALL_ARMV7-NEXT: size 304
# CHECK_SMALL_ARMV7-NEXT: align 2^8 (256)
# CHECK_SMALL_ARMV7-NEXT: architecture i386
# CHECK_SMALL_ARMV7: offset 4096
# CHECK_SMALL_ARMV7-NEXT: size 432
# CHECK_SMALL_ARMV7-NEXT: align 2^12 (4096)
# CHECK_SMALL_ARMV7-NEXT: architecture x86_64
# CHECK_SMALL_ARMV7: offset 8192
# CHECK_SMALL_ARMV7-NEXT: size 488
# CHECK_SMALL_ARMV7-NEXT: align 2^12 (4096)
######     WITHOUT SEGALIGN      ######
# RUN: llvm-lipo %t-universal.o %t-armv7.o -create -o %t2-nosegalign.o
# RUN: llvm-objdump %t2-nosegalign.o -m --universal-headers | FileCheck --check-prefix=CHECK_SMALL_ARMV7_NO_SEGALIGN %s
# CHECK_SMALL_ARMV7_NO_SEGALIGN: nfat_arch 3
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: architecture i386
# CHECK_SMALL_ARMV7_NO_SEGALIGN: offset 4096
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: size 432
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: align 2^12 (4096)
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: architecture x86_64
# CHECK_SMALL_ARMV7_NO_SEGALIGN: offset 8192
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: size 488
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: align 2^12 (4096)
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: architecture armv7
# CHECK_SMALL_ARMV7_NO_SEGALIGN: offset 16384
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: size 304
# CHECK_SMALL_ARMV7_NO_SEGALIGN-NEXT: align 2^14 (16384)

# RUN: llvm-lipo %t2.o -thin armv7 -o %thin-armv7.o
# RUN: cmp %thin-armv7.o %t-armv7.o

# RUN: yaml2obj %p/Inputs/armv7-slice-big.yaml -o %t-armv7-big.o
# RUN: yaml2obj %p/Inputs/i386-x86_64-armv7-arm64-universal.yaml -o %t-universal-big.o

# RUN: llvm-lipo %t-universal-big.o -replace armv7 %t-armv7-big.o -o %t3.o -segalign armv7 4
# RUN: llvm-objdump %t3.o -m --universal-headers | FileCheck --check-prefix=CHECK_REPLACE_ARMV7 %s
# CHECK_REPLACE_ARMV7: nfat_arch 4
# CHECK_REPLACE_ARMV7-NEXT: architecture armv7
# CHECK_REPLACE_ARMV7: offset 88
# CHECK_REPLACE_ARMV7-NEXT: size 88128
# CHECK_REPLACE_ARMV7-NEXT: align 2^2 (4)
# CHECK_REPLACE_ARMV7-NEXT: architecture i386
# CHECK_REPLACE_ARMV7: offset 90112
# CHECK_REPLACE_ARMV7-NEXT: size 432
# CHECK_REPLACE_ARMV7-NEXT: align 2^12 (4096)
# CHECK_REPLACE_ARMV7-NEXT: architecture x86_64
# CHECK_REPLACE_ARMV7: offset 94208
# CHECK_REPLACE_ARMV7-NEXT: size 488
# CHECK_REPLACE_ARMV7-NEXT: align 2^12 (4096)
# CHECK_REPLACE_ARMV7-NEXT: architecture arm64
# CHECK_REPLACE_ARMV7: offset 98304
# CHECK_REPLACE_ARMV7-NEXT: size 516
# CHECK_REPLACE_ARMV7-NEXT: align 2^14 (16384)
######     WITHOUT SEGALIGN      ######
# RUN: llvm-lipo %t-universal-big.o -replace armv7 %t-armv7-big.o -o %t3-nosegalign.o
# RUN: llvm-objdump %t3-nosegalign.o -m --universal-headers | FileCheck --check-prefix=CHECK_REPLACE_ARMV7_NO_SEGALGIN %s
# CHECK_REPLACE_ARMV7_NO_SEGALGIN: nfat_arch 4
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture i386
# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 4096
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 432
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^12 (4096)
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture x86_64
# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 8192
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 488
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^12 (4096)
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture armv7
# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 16384
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 88128
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^14 (16384)
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: architecture arm64
# CHECK_REPLACE_ARMV7_NO_SEGALGIN: offset 114688
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: size 516
# CHECK_REPLACE_ARMV7_NO_SEGALGIN-NEXT: align 2^14 (16384)


# RUN: llvm-lipo %t3.o -thin armv7 -o %thin-armv7-big.o
# RUN: cmp %thin-armv7-big.o %t-armv7-big.o
